<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            margin: 200px;
            
        }
        img{
            width: 50px;
            height: 50px;

        }
    </style>
</head>
<body>
    <div>
        <img src="/Users/D盘/JavaScript练习/picture/IMG_3905.GIF" alt="">
        <img src="/Users/D盘/JavaScript练习/picture/IMG_3903.GIF" alt="">
        <img src="/Users/D盘/JavaScript练习/picture/IMG_3900.GIF" alt="">
        <img src="/Users/D盘/JavaScript练习/picture/IMG_3895.GIF" alt="">
    </div>
    <script>
        var img = document.getElementsByTagName('img');
        for(var i = 0 ;i<img.length;i++){
            img[i].onclick = function(){
                for(var i = 0;i<img.length;i++){
                    document.body.backgroundImage = '';
                }
                document.body.style.backgroundImage = 'url('+this.src+')';
            }
        }
    </script>
</body>
</html>